#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

//----------------------------------------------------------------------------//

CLIPPER OPENCLIPBO()  // ARD
{
   _retl( OpenClipboard( _parni( 1 ) ) );
}

//----------------------------------------------------------------------------//

CLIPPER CLOSECLIPB()   // OARD()
{
   _retl( CloseClipboard() );
}

//----------------------------------------------------------------------------//

CLIPPER EMPTYCLIPB()   // OARD()
{
   _retl( EmptyClipboard() );
}

//----------------------------------------------------------------------------//

CLIPPER SETCLIPBOA()    // RDDATA()
{
   WORD wType = _parni( 1 );
   WORD wLen;
   HGLOBAL hMem;
   void far * pMem;

   if( PCOUNT() > 1 )
   {
      switch( wType )
      {
         case CF_TEXT:
              wLen = _parclen( 2 );
              hMem = GlobalAlloc( GHND, wLen + 1 );
              pMem = GlobalLock( hMem );
              _bcopy( pMem, _parc( 2 ), wLen );
              GlobalUnlock( hMem );
              _retl( ( BOOL ) SetClipboardData( CF_TEXT, hMem ) );
              break;
      }
   }
}

//----------------------------------------------------------------------------//

CLIPPER GETCLPDATA()     // GETCLIPBOARDDATA()
{
   WORD wType = _parni( 1 );
   HGLOBAL hMem;

   switch( wType )
   {
      case CF_TEXT:
           if( hMem = GetClipboardData( CF_TEXT ) )
           {
              _retc( GlobalLock( hMem ) );
              GlobalUnlock( hMem );
           }
           else
              _retc( "" );
           break;
   }
}

//----------------------------------------------------------------------------//
